package com.example.children.yyz;

import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/achievements")
public class AchievementController {

    private TAListService taListService = new TAListService();

    @GetMapping("/getAllAchievements")//所有
    public List<TechnicalAchievement> getAllAchievements() {
        System.out.println("getAllAchievements方法：");
        return taListService.getAchievements();
    }

    @GetMapping("/getAchievementById")   //id,一对一
    public TechnicalAchievement getAchievementById(@RequestParam String id) {
        System.out.println("getAchievementById方法：");
        return taListService.getAchievementById(id);
    }

    @PostMapping("/addAchievement")  //添加
    public void addAchievement(@RequestBody TechnicalAchievement achievement) {
        System.out.println("addAchievement方法：");
        taListService.addAchievement(achievement);
    }

    @PutMapping("/updateAchievement")   //修改
    public void updateAchievement(@RequestParam String id, @RequestBody TechnicalAchievement achievement) {
        System.out.println("updateAchievement方法：");
        taListService.updateAchievement(id, achievement);
    }

    @DeleteMapping("/deleteAchievement")   //删除
    public void deleteAchievement(@RequestParam String id) {
        System.out.println("deleteAchievement方法：");
        taListService.deleteAchievement(id);
    }
}

